#include <iostream>
using namespace std;

class CDateType {
private:
	int y, m, d;
public:
	CDateType(int year,int month,int day):y(year),m(month),d(day) {}
	void IncrementDay() {
		if (m==1||m==3||m==5||m==7||m==8||m==10) {
			if (1 <= d <= 30) {
				d = d + 1;
			}
			if (d == 31) {
				m = m + 1;
				d = 1;
			}
		}
        cout << "d1 = " << d << endl;
		if (m == 4 ||m== 6 ||m== 9 ||m== 11 ) {
			if (1 <= d <= 29) {
				d = d + 1;
			}
			if (d == 30) {
				d = 1;
				m = m + 1;
			}
		}
        cout << "d2 = " << d << endl;
		if (m == 12) {
            
			if (1 <= d && d <= 30) {
				d = d + 1;
			}
            cout << "d = " << d << endl;
			if (d == 31) {
				y = y + 1;
				d = 1;
				m = 1;
                cout << "1212" << endl;
			}
		}
		if (m == 2) {
			if ((y % 4 == 0 && y % 100 != 0) || y % 400 == 0) {//闰年
				if (1 <= d && d <= 28) {
					d = d + 1;
				}
				if (d == 29) {
					d = 1;
					m = 3;
				}
			}
			else {
				if (1 <= d && d <= 27) {
					d = d + 1;
				}
				if (d == 28) {
					d = 1;
					m = 3;
				}
			}
		}
	}
	int Equal(CDateType dt2) {
		if (dt2.d == d && dt2.y == y && dt2.m == m) { return 1; }
		else { return 0; }
	}
	void PrintData() {
		cout << y << ' ' << m << ' ' << d << endl;
	}
};
int main() {
	int y1, y2, m1, m2, d1, d2;
	cin >> y1 >> m1 >> d1; //>> y2 >> m2 >> d2;
	CDateType dt1(y1, m1, d1);
	//CDateType dt2(y2, m2, d2);
	dt1.PrintData();
	//dt2.PrintData();
	//cout<<dt1.Equal(dt2)<<endl;
	dt1.IncrementDay();
	//dt2.IncrementDay();
	dt1.PrintData();
	//dt2.PrintData();
	//cout << dt1.Equal(dt2) << endl;
	return 0;
}